//
//  ViewController.swift
//  CAReplicatorLayer
//
//  Created by YYKJ on 2021/4/9.
//

import UIKit

class ViewController: UITableViewController {
    
    let dataSource = [
        "CAReplicatorLayer"
    ]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellId")
        self.tableView.reloadData()
    }
    
}

// MARK:

extension ViewController {
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSource.count;
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cellId")
        cell?.accessoryType = .disclosureIndicator
        cell?.textLabel?.text = dataSource[indexPath.row]
        guard let warpperCell = cell else { return UITableViewCell() }
        return warpperCell
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let title = dataSource[indexPath.row]
        switch title {
        case "CAReplicatorLayer":
            self.present(CAReplicatorVC(), animated: true, completion: nil)
        default:
            print("default")
        }
    }
}

